#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main(void)
{
    pid_t pid;

    pid = fork();
    switch (pid) {
        case -1:
            perror("fork error");
            exit(-1);
        case 0:                             // first enter
            printf("This sfork print!\n");
            printf("current pid: %d, ffork pid: %d\n", getpid(), getppid());
            _exit(0);
        default:                            // second enter
            printf("This ffork print!\n");
            printf("current pid: %d, sfork pid: %d\n", getpid(), pid);
            exit(0);
    }
}